package com.manager.common.utils;

import com.manager.common.constant.ResultVOEnum;

import java.io.Serializable;

public class ResultVO<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    private int code;

    private String msg;

    private T data;

    public ResultVO() {}

    public ResultVO(ResultVOEnum resultVOEnum){
        this.code = resultVOEnum.getCode();
        this.msg = resultVOEnum.getMsg();
    }
    public ResultVO(ResultVOEnum resultVOEnum, String message){
        this.code = resultVOEnum.getCode();
        this.msg = message;
    }

    public ResultVO(ResultVOEnum resultVOEnum, String massage, T data){
        this.code = resultVOEnum.getCode();
        this.msg = massage;
        this.data = data;
    }

    public static <T> ResultVO<T> success(){
        return new ResultVO<>(ResultVOEnum.SUCCESS);
    }

    public static <T> ResultVO<T> success(String msg){
        return new ResultVO<>(ResultVOEnum.SUCCESS,msg);
    }

    public static <T> ResultVO<T> success(String msg, T data){
        return new ResultVO<>(ResultVOEnum.SUCCESS,msg,data);
    }

    public static <T> ResultVO<T> success(T data){
        return new ResultVO<>(ResultVOEnum.SUCCESS,ResultVOEnum.SUCCESS.getMsg(),data);
    }

    public static <T> ResultVO<T> failed(){
        return new ResultVO<>(ResultVOEnum.FAILED);
    }

    public static <T> ResultVO<T> failed(String msg){
        return new ResultVO<>(ResultVOEnum.FAILED,msg);
    }

    public static <T> ResultVO<T> failed(String msg, T data){
        return new ResultVO<>(ResultVOEnum.FAILED,msg,data);
    }

    public static <T> ResultVO<T> failed(T data){
        return new ResultVO<>(ResultVOEnum.FAILED,ResultVOEnum.FAILED.getMsg(),data);
    }

    public static <T> ResultVO<T> failed(ResultVOEnum resultVOEnum){
        return new ResultVO<>(resultVOEnum);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }


    public static void main(String[] args) {

    }
}
